package org.moore.view;

import javax.swing.*;
import java.awt.*;

// 游戏菜单类
public class GameBar extends JMenuBar {
	// 【开始】菜单子项目
    private final JMenuItem startItem = new JMenuItem("开始游戏");
    private final JMenuItem restartItem = new JMenuItem("重新开始");
    private final JMenuItem exitItem = new JMenuItem("退出游戏");
    private final JMenuItem roadItem = new JMenuItem("存档");
    private final JMenuItem rankingListItem = new JMenuItem("排行榜");
    private final JMenuItem homeItem = new JMenuItem("主界面");


    // 【游戏】菜单子项目
    private final JMenuItem blockColorItem = new JMenuItem("色块颜色数量");
    private final JMenuItem mapShapeItem = new JMenuItem("地图形状");
    private final JMenuItem obstaclesNumberItem = new JMenuItem("障碍物数量");
    private final JMenuItem obstaclesDisappearItem = new JMenuItem("障碍物消失");
    private final JMenuItem obstaclesAppearItem = new JMenuItem("障碍物出现");
    private final JMenuItem musicOnItem = new JMenuItem("音效开");
    private final JMenuItem musicOffItem = new JMenuItem("音效关");
    private final JMenuItem gameModeItem = new JMenuItem("游戏模式");
    private final JMenuItem stepsNumberItem = new JMenuItem("初始步数");
    private final JMenuItem timeNumberItem = new JMenuItem("初始时间");
    private final JMenuItem lowerModeItem = new JMenuItem("初级");
    private final JMenuItem middenModeItem = new JMenuItem("中级");
    private final JMenuItem premiumModeItem = new JMenuItem("高级");

    // 【帮助】菜单
    private final JMenu helpMenu = new JMenu("帮助菜单");
    // 子项目
    private final JMenuItem introItem = new JMenuItem("规则");
    private final JMenuItem aboutItem = new JMenuItem("关于");

    // 【捐赠】菜单
    private final JMenuItem donationItem = new JMenuItem("捐赠一杯快乐水吧~");

    // 空参构造
    public GameBar() {
        // 【游戏】菜单
        JMenu gameMenu = new JMenu("游戏菜单");
        // 【自定义】菜单
        JMenu customMenu = new JMenu("自定义");
        // 【捐赠】菜单
        JMenu donationMenu = new JMenu("捐赠");
        // 创建字体
        Font font = new Font("宋体", Font.PLAIN, 18);
        // 默认不可点击的按钮
        restartItem.setEnabled(false);
        homeItem.setEnabled(false);
        musicOnItem.setEnabled(false);
        musicOnItem.setText("音效开[√]");

        // 设置字体
        gameMenu.setFont(font);
        startItem.setFont(font);
        restartItem.setFont(font);
        exitItem.setFont(font);
        roadItem.setFont(font);
        rankingListItem.setFont(font);
        homeItem.setFont(font);
        blockColorItem.setFont(font);
        mapShapeItem.setFont(font);
        obstaclesNumberItem.setFont(font);
        obstaclesDisappearItem.setFont(font);
        obstaclesAppearItem.setFont(font);
        musicOffItem.setFont(font);
        musicOnItem.setFont(font);
        gameModeItem.setFont(font);
        stepsNumberItem.setFont(font);
        timeNumberItem.setFont(font);
        lowerModeItem.setFont(font);
        middenModeItem.setFont(font);
        premiumModeItem.setFont(font);
        introItem.setFont(font);
        aboutItem.setFont(font);
        customMenu.setFont(font);
        helpMenu.setFont(font);
        donationMenu.setFont(font);
        donationItem.setFont(font);

        // 添加二级项至菜单
        // 【游戏】菜单
        gameMenu.add(startItem);
        gameMenu.add(restartItem);
        gameMenu.add(exitItem);
        gameMenu.add(roadItem);
        gameMenu.add(rankingListItem);
        gameMenu.add(homeItem);

        // 【自定义】菜单
        customMenu.add(blockColorItem);
        customMenu.add(mapShapeItem);
        customMenu.add(obstaclesNumberItem);
        customMenu.add(obstaclesDisappearItem);
        customMenu.add(obstaclesAppearItem);
        customMenu.add(musicOnItem);
        customMenu.add(musicOffItem);
        customMenu.add(gameModeItem);
        customMenu.add(stepsNumberItem);
        customMenu.add(timeNumberItem);
        customMenu.add(lowerModeItem);
        customMenu.add(middenModeItem);
        customMenu.add(premiumModeItem);

        // 【帮助】菜单
        helpMenu.add(introItem);
        helpMenu.add(aboutItem);

        // 【捐赠】菜单
        donationMenu.add(donationItem);

        // 添加主菜单至菜单栏
        this.add(gameMenu);
        this.add(customMenu);
        this.add(helpMenu);
        this.add(donationMenu);

        // 设置动作命令
        // 【游戏】菜单
        startItem.setActionCommand("start");
        restartItem.setActionCommand("restart");
        exitItem.setActionCommand("exit");
        roadItem.setActionCommand("road");
        rankingListItem.setActionCommand("rankingList");
        homeItem.setActionCommand("home");

        // 【自定义】菜单
        blockColorItem.setActionCommand("blockColor");
        mapShapeItem.setActionCommand("mapShape");
        obstaclesNumberItem.setActionCommand("obsNum");
        obstaclesDisappearItem.setActionCommand("obsDisappear");
        obstaclesAppearItem.setActionCommand("obsAppear");
        musicOffItem.setActionCommand("musicOff");
        musicOnItem.setActionCommand("musicOn");
        gameModeItem.setActionCommand("gameMode");
        stepsNumberItem.setActionCommand("stepsNumber");
        timeNumberItem.setActionCommand("timeNumber");
        lowerModeItem.setActionCommand("lower");
        middenModeItem.setActionCommand("midden");
        premiumModeItem.setActionCommand("premium");

        // 【帮助】菜单
        introItem.setActionCommand("intro");
        aboutItem.setActionCommand("about");

        // 【捐赠】菜单
        donationItem.setActionCommand("donation");
    }

    public JMenuItem getStartItem() {
        return startItem;
    }

    public JMenuItem getRestartItem() {
        return restartItem;
    }

    public JMenuItem getExitItem() {
        return exitItem;
    }

    public JMenuItem getRoadItem() {
        return roadItem;
    }

    public JMenuItem getRankingListItem() {
        return rankingListItem;
    }

    public JMenuItem getHomeItem() {
        return homeItem;
    }

    public JMenuItem getBlockColorItem() {
        return blockColorItem;
    }

    public JMenuItem getMapShapeItem() {
        return mapShapeItem;
    }

    public JMenuItem getObstaclesNumberItem() {
        return obstaclesNumberItem;
    }

    public JMenuItem getObstaclesDisappearItem() {
        return obstaclesDisappearItem;
    }

    public JMenuItem getObstaclesAppearItem() {
        return obstaclesAppearItem;
    }

    public JMenuItem getMusicOnItem() {
        return musicOnItem;
    }

    public JMenuItem getMusicOffItem() {
        return musicOffItem;
    }

    public JMenuItem getGameModeItem() {
        return gameModeItem;
    }

    public JMenuItem getStepsNumberItem() {
        return stepsNumberItem;
    }

    public JMenuItem getTimeNumberItem() {
        return timeNumberItem;
    }

    public JMenuItem getLowerModeItem() {
        return lowerModeItem;
    }

    public JMenuItem getMiddenModeItem() {
        return middenModeItem;
    }

    public JMenuItem getPremiumModeItem() {
        return premiumModeItem;
    }

    @Override
    public JMenu getHelpMenu() {
        return helpMenu;
    }

    public JMenuItem getIntroItem() {
        return introItem;
    }

    public JMenuItem getAboutItem() {
        return aboutItem;
    }

    public JMenuItem getDonationItem() {
        return donationItem;
    }
}
